package exception;

/**
 *
 * 我是你爷爷
 *
 */
public class Person1
{
    private int age;

    public int getAge()
    {
        return age;
    }

    public void setAge(int age) throws IllegalAgeException
    {
        if (age < 0 || age > 100)
        {
//            throw new Exception("年龄不合法");
//            throw new RuntimeException("你牛逼啊");  // throw 也有结束方法的功能
            throw  new IllegalAgeException("年龄超出了范围(0-100)" + age);
        }
        this.age = age;
    }
}
